package com.test.designmode.abstactfactory;

import com.test.designmode.abstactfactory.colorcreate.ColorFactory;
import com.test.designmode.abstactfactory.shapecreate.ShapeFactory;

/**
 * 创建一个工厂创造器/生成器类，通过传递形状或颜色信息来获取工厂
 */
public class FactoryCreator {

    /**
     * 根据参数 创建需要的目标工厂
     * @param choice  参数
     * @return AbstractFactory
     */
    public static AbstractFactory getFactory(String choice){
        if(choice.equalsIgnoreCase("SHAPE")){
            return new ShapeFactory();
        } else if(choice.equalsIgnoreCase("COLOR")){
            return new ColorFactory();
        }
        return null;
    }
}
